<?php

namespace App\Http\Services;

use App\Http\Model\FinanceUserWallet;

/**
 * 用户钱包
 *
 * Created on 2021/11/11 17:34
 * @Author <yuxiang.zhu@asiainnovations.net>
 */
class FinanceWalletServices extends CommonServices
{
    /**
     * @var FinanceUserWallet
     */
    private $model_finance_user_wallet;

    /**
     * 构造函数
     */
    public function __construct()
    {
        parent::__construct();
        $this->model_finance_user_wallet = new FinanceUserWallet();
    }

    /**
     * 检测用户财富值是否大于某个值
     *
     * Created at 2021/11/11 17:35
     * @Author <yuxiang.zhu@asiainnovations.net>
     * @param int $userId
     * @param int $number
     * @return bool
     */
    public function checkUserWealthBalanceGreaterThanNumber(int $userId, int $number)
    {
        $userWallet = $this->model_finance_user_wallet->get_wallet($userId);
        if ($userWallet && isset($userWallet['wealth_balance']) && $userWallet['wealth_balance'] >= $number) {
            return true;
        }

        return false;
    }

    /**
     * 检测用户魅力是否大于某个值
     *
     * Created at 2021/11/11 17:35
     * @Author <yuxiang.zhu@asiainnovations.net>
     * @param int $userId
     * @param int $number
     * @return bool
     */
    public function checkUserCharmBalanceGreaterThanNumber(int $userId, int $number)
    {
        $userWallet = $this->model_finance_user_wallet->get_wallet($userId);
        if ($userWallet && isset($userWallet['charm_balance']) && $userWallet['charm_balance'] >= $number) {
            return true;
        }

        return false;
    }
}